﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TcpTestServer.DataLayer
{
    class MessageBuffer
    {
        public void addMessageToBuffer(Message m)
        {
            if(_buff != null)
                throw new InvalidOperationException("Buffer full");
            else
                _buff = m;
        }
        public Message getMessage()
        {
            if (_buff == null)
                throw new InvalidOperationException("No message in the buffer");
            else
            {
                return _buff;
            }
        }
        public void disposeMessage()
        {
            _buff = null; 
        }
        public bool HasMessage
        {
            get
            {
                return (_buff == null) ? false : true;
            }
        }
        public bool IsFull
        {
            get
            {
                return HasMessage;
            }
        }


        private Message _buff = null;
    }
}
